package me.zhengjie.business.rest;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.business.domain.sup.Gsgl;
import me.zhengjie.business.repository.ZhsqRepository;
import me.zhengjie.business.service.GsglService;
import me.zhengjie.business.service.OrgPageService;
import me.zhengjie.business.service.dto.GeneralQueryCriteria;
import me.zhengjie.utils.DateTimeUtil;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.SecurityUtils;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lyl
 * @since 2023/11/21
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@Api(tags = "首页统计")
@RequestMapping("/api/orgPage")
public class OrgPageController {

    private final OrgPageService orgPageService;
    private final GsglService gsglService;

    @GetMapping(value = "/querOrgPageList")
    @ApiOperation("照护首页统计查询")
    public ResponseEntity<Object> querOrgPageList() {

        GeneralQueryCriteria criteria = new GeneralQueryCriteria();
        Long userid = SecurityUtils.getCurrentUserId();
        Gsgl gsgl = gsglService.queryGsgl(userid);
        criteria.setDdbm(gsgl.getBisGsglYljgdm());
        criteria.setZhlb("01");

        List<String> list = new ArrayList<>();


        criteria.setZtList(list);
        criteria.setInZt("true");
        criteria.setBisZhsqDyjsrq2(DateTimeUtil.getDateTime(DateTimeUtil.addDays(+5), DateTimeUtil.DEFAULT_DATE_FORMAT));
        criteria.setBisZhsqDyjsrq1(DateTimeUtil.getDateTime(DateTimeUtil.getNow(), DateTimeUtil.DEFAULT_DATE_FORMAT));
        Object o = orgPageService.querOrgPageList(criteria.getDdbm(), criteria.getZhlb(), criteria.getBisZhsqDyjsrq2(), criteria.getBisZhsqDyjsrq1());

        return new ResponseEntity<>(o, HttpStatus.OK);
    }

}
